-
Notifications
You must be signed in to change notification settings - Fork 105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce SDMMC write_blocks
#453
Conversation
The read check is processing a buffer 10 blocks long. The check then reads data from the SD card 10 times to then report the speed of "Read 10 blocks at X bytes/second". The problem is that it actually reads 10*10 blocks. With this patch, read_blocks is used correctly to populate a continuous buffer. Signed-off-by: Petr Horacek <[email protected]>
d01305a
to
0c61690
Compare
c41dabd
to
117f43a
Compare
Strange, we seem to have come up with a PR to solve this at the same time. I use CMD23 to set the SD block length for the transfer, which may help, see #455 |
@ostenning ha! 😁 Interesting, I did not know CMD23 can be used instead of CMD12 for SD. I tried using CMD23 from your patch in my benchmark instead of |
I'm sure @richardeoin will have greater insights |
Thanks @ostenning. I have posted a draft of this new method being used in FAT writes. It still needs some care, so I keep it in a separate PR: #456 |
`write_block` needs to be called for every 512 bytes long block that is to be written to the SD card. Each of these calls requires the overhead of negotiating the write command. With this patch, `write_blocks` is introduced, mirroring the behavior of `read_block` and `read_blocks`. This new method helped me to improve write speed of the original 9492 kB/s to 66252 kB/s. Signed-off-by: Petr Horacek <[email protected]>
117f43a
to
7277293
Compare
Great! I don't have any specific insights, other than that this looks like a nice PR. It's possible that some cards use CMD23 to optimise writes, but here I like the simplicity of having It looks like this PR is ready, so I'll go ahead and merge it |
write_block
needs to be called for every 512 bytes long block that is to be written to the SD card. Each of these calls requires the overhead of negotiating the write command and if I understand it correctly it also requires to erase the whole SD segment and copying it back.Speed
With this patch,
write_blocks
is introduced, mirroring the behavior ofread_block
andread_blocks
. This new method by itself helped me to improve write speed from the original example of 9.2 kB/s to 65 kB/s.Write performance with 480 MHz system clock, 50 MHz bus speed, and enabled caches:
Erase before writing
Using ACMD23 to erase block data before writing in my case did not improve the result. Either my card does not benefit from it or I used it wrong.
Possible improvements
Although the results look good Class 10 SD cards should be much faster. Even with half the bus speed, it should achieve at least 10 MB/s. If anybody has an idea what may be the bottleneck, please share.
Follow ups